/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AirfoilView.java
 *
 * Created on Dec 18, 2009, 8:03:03 PM
 */

package Views;

import Core.DataServer;
import Core.GlobalValue;
import Core.OAE_DataLink;
import Core.OAE_LinkedTable;
import Core.OAE_ViewComponent;
import Project.ProjectWizard;
import Services.ExcelAdapter;
import Services.ImportExportService;
import Services.StreamService;
import java.util.Vector;
import javax.swing.JTextField;
import opendatcom.OpenDatcomController;

/**
 *
 * @author -B-
 */
public class AirfoilView extends OAE_ViewComponent {

    public enum AIRFOIL_TYPE
    {
        WGSCHR,
        HTSCHR,
        VTSCHR,
        VFSCHR
    }
    AIRFOIL_TYPE type;
    String prefix;


    /** Creates new form AirfoilView */
    public AirfoilView(AIRFOIL_TYPE type) {
        initComponents();
        this.type = type;
        this.name = type.toString();
        jTitle.setText(name + " Parameters");
        ExcelAdapter ea = new ExcelAdapter(jTable1);
        initView(name);
    }

    public void registerLinks()
    {
        prefix  = this.name.substring(0, 2) + "_";
        parent.addLink(new OAE_DataLink(prefix + "T0VC",      jT0VC,    double.class));
        parent.addLink(new OAE_DataLink(prefix + "DELTAY",    jDELTAY,  double.class));
        parent.addLink(new OAE_DataLink(prefix + "X0VC",      jX0VC,    double.class));
        parent.addLink(new OAE_DataLink(prefix + "CLI",       jCLI,     double.class));
        parent.addLink(new OAE_DataLink(prefix + "ALPHAI",    jALPHAI,  double.class));
        parent.addLink(new OAE_DataLink(prefix + "CM0",       jCM0,     double.class));
        parent.addLink(new OAE_DataLink(prefix + "LERI",      jLERI,    double.class));
        parent.addLink(new OAE_DataLink(prefix + "LER0",      jLER0,    double.class));
        parent.addLink(new OAE_DataLink(prefix + "T0VC0",     jT0VC0,   double.class));
        parent.addLink(new OAE_DataLink(prefix + "X0VC0",     jX0VC0,   double.class));
        parent.addLink(new OAE_DataLink(prefix + "CM0T",      jCM0T,    double.class));
        parent.addLink(new OAE_DataLink(prefix + "CLMAXL",    jCLMAXL,  double.class));
        parent.addLink(new OAE_DataLink(prefix + "CLAMO",     jCLAM0,   double.class));
        parent.addLink(new OAE_DataLink(prefix + "TCEFF",     jTCEFF,   double.class));
        parent.addLink(new OAE_DataLink(prefix + "KSHARP",    jKSHARP,  double.class));
        parent.addLink(new OAE_DataLink(prefix + "ARCC",      jARCC,    double.class));
        parent.addLink(new OAE_LinkedTable(prefix + "XCORD", jTable1, 0));
        parent.addLink(new OAE_LinkedTable(prefix + "YUPPER", jTable1, 1));
        parent.addLink(new OAE_LinkedTable(prefix + "YLOWER", jTable1, 2));
        parent.addLink(new OAE_LinkedTable(prefix + "MEAN", jTable1, 1));
        parent.addLink(new OAE_LinkedTable(prefix + "THICK", jTable1, 2));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTitle = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jT0VC = new javax.swing.JTextField();
        jDELTAY = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jX0VC = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jCLI = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jALPHAI = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jCM0 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLERI = new javax.swing.JTextField();
        jLER0 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jT0VC0 = new javax.swing.JTextField();
        jX0VC0 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jCM0T = new javax.swing.JTextField();
        jCLMAXL = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jCLAM0 = new javax.swing.JTextField();
        jTCEFF = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jKSHARP = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jARCC = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jClearTable = new javax.swing.JButton();
        jImportAirfoil = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        jAirfoilName = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jNPTS = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(opendatcom.OpenDatcomController.class).getContext().getResourceMap(AirfoilView.class);
        jTitle.setFont(resourceMap.getFont("jTitle.font")); // NOI18N
        jTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jTitle.setText(resourceMap.getString("jTitle.text")); // NOI18N
        jTitle.setName("jTitle"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 887, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setName("jPanel2"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jT0VC.setText(resourceMap.getString("jT0VC.text")); // NOI18N
        jT0VC.setName("jT0VC"); // NOI18N
        jT0VC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jT0VCActionPerformed(evt);
            }
        });

        jDELTAY.setText(resourceMap.getString("jDELTAY.text")); // NOI18N
        jDELTAY.setName("jDELTAY"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jX0VC.setText(resourceMap.getString("jX0VC.text")); // NOI18N
        jX0VC.setName("jX0VC"); // NOI18N
        jX0VC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jX0VCActionPerformed(evt);
            }
        });

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jCLI.setText(resourceMap.getString("jCLI.text")); // NOI18N
        jCLI.setName("jCLI"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jALPHAI.setText(resourceMap.getString("jALPHAI.text")); // NOI18N
        jALPHAI.setName("jALPHAI"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jCM0.setText(resourceMap.getString("jCM0.text")); // NOI18N
        jCM0.setName("jCM0"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLERI.setText(resourceMap.getString("jLERI.text")); // NOI18N
        jLERI.setName("jLERI"); // NOI18N

        jLER0.setText(resourceMap.getString("jLER0.text")); // NOI18N
        jLER0.setName("jLER0"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jT0VC0.setText(resourceMap.getString("jT0VC0.text")); // NOI18N
        jT0VC0.setName("jT0VC0"); // NOI18N

        jX0VC0.setText(resourceMap.getString("jX0VC0.text")); // NOI18N
        jX0VC0.setName("jX0VC0"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jCM0T.setText(resourceMap.getString("jCM0T.text")); // NOI18N
        jCM0T.setName("jCM0T"); // NOI18N

        jCLMAXL.setText(resourceMap.getString("jCLMAXL.text")); // NOI18N
        jCLMAXL.setName("jCLMAXL"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jCM0, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                            .addComponent(jALPHAI, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                            .addComponent(jCLI, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                            .addComponent(jX0VC, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                            .addComponent(jDELTAY, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                            .addComponent(jT0VC, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel9)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jCLMAXL, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jCM0T, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jX0VC0, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jT0VC0, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jLER0, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                            .addComponent(jLERI, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jT0VC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jDELTAY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jX0VC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jCLI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jALPHAI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jCM0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLERI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLER0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jT0VC0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jX0VC0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jCM0T, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jCLMAXL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jPanel3.setName("jPanel3"); // NOI18N

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        jCLAM0.setText(resourceMap.getString("jCLAM0.text")); // NOI18N
        jCLAM0.setName("jCLAM0"); // NOI18N

        jTCEFF.setText(resourceMap.getString("jTCEFF.text")); // NOI18N
        jTCEFF.setName("jTCEFF"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jKSHARP.setText(resourceMap.getString("jKSHARP.text")); // NOI18N
        jKSHARP.setName("jKSHARP"); // NOI18N

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jARCC.setText(resourceMap.getString("jARCC.text")); // NOI18N
        jARCC.setName("jARCC"); // NOI18N
        jARCC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jARCCActionPerformed(evt);
            }
        });

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTCEFF))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCLAM0, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jARCC, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jKSHARP, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jCLAM0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTCEFF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jKSHARP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jARCC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel4.setName("jPanel4"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "X", "Value 1", "Value 2"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 484, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addGap(5, 5, 5)
                    .addComponent(jScrollPane1)
                    .addContainerGap()))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 375, Short.MAX_VALUE)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                    .addContainerGap()))
        );

        jPanel5.setName("jPanel5"); // NOI18N

        jClearTable.setText(resourceMap.getString("jClearTable.text")); // NOI18N
        jClearTable.setName("jClearTable"); // NOI18N
        jClearTable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jClearTableActionPerformed(evt);
            }
        });

        jImportAirfoil.setText(resourceMap.getString("jImportAirfoil.text")); // NOI18N
        jImportAirfoil.setName("jImportAirfoil"); // NOI18N
        jImportAirfoil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jImportAirfoilActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "YUpper/YLower", "Mean/Thick" }));
        jComboBox1.setName("jComboBox1"); // NOI18N

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jAirfoilName.setText(resourceMap.getString("jAirfoilName.text")); // NOI18N
        jAirfoilName.setName("jAirfoilName"); // NOI18N

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        jNPTS.setEnabled(false);
        jNPTS.setName("jNPTS"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jClearTable, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(jImportAirfoil, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(jComboBox1, 0, 151, Short.MAX_VALUE)
                    .addComponent(jLabel17)
                    .addComponent(jAirfoilName, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(jLabel18)
                    .addComponent(jNPTS, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addComponent(jLabel19))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jAirfoilName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jNPTS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 223, Short.MAX_VALUE)
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jImportAirfoil)
                .addGap(18, 18, 18)
                .addComponent(jClearTable)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jT0VCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jT0VCActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jT0VCActionPerformed

    private void jX0VCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jX0VCActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jX0VCActionPerformed

    private void jARCCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jARCCActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jARCCActionPerformed

    private void jImportAirfoilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jImportAirfoilActionPerformed
        String text = ImportExportService.getInstance().importFile_FC();
        if(text == null)
        {
            StreamService.print("No Airfoil File Chosen, aborting import");
        }
        text = text.replaceAll(" ", ",");
        StreamService.print(text);
        String [] lines = text.split("\n");
        String [] currLine;
        // Initialize the vectors to a nice big size to speed up processing
        Vector<Double> x = new Vector<Double>(200);
        Vector<Double> yUpper = new Vector<Double>(100);
        Vector<Double> yLower = new Vector<Double>(100);

        // Reverse the changes made to the 1st line and set the airfoil name
        lines[0] = lines[0].replaceAll(",", " ");
        jAirfoilName.setText(lines[0]);

        // Init the control variables
        int breakPoint = -1;

        // Throw away the first 3 lines cause they are garbage
        for(int i = 3; i < lines.length; i++)
        {
            currLine = lines[i].split(",");
            if(currLine.length == 3)
            {
                x.add(Double.parseDouble(currLine[1]));
                if(breakPoint > 0)
                {
                    yLower.add(Double.parseDouble(currLine[2]));
                }
                else
                {
                    yUpper.add(Double.parseDouble(currLine[2]));
                }
            }
            else if(currLine.length == 2)
            {
                x.add(Double.parseDouble(currLine[0]));
                if(breakPoint > 0)
                {
                    yLower.add(Double.parseDouble(currLine[1]));
                }
                else
                {
                    yUpper.add(Double.parseDouble(currLine[1]));
                }
            }
            else if(currLine.length == 1)
            {
                StreamService.print("Break found at line:" + i);
                breakPoint = i - 3;
            }
        }
        int npts = Math.min(yUpper.size(), yLower.size());

        // Make sure that the airfoil corresponds to datcom format, and if not
        // modify it to correspond
        if(x.firstElement() != 0)
        {
            StreamService.print("X(1) is not 0.0 as per DATCOM requirements, overriding:\n" +
                    "\tX(0)  to 0.0\n" +
                    "\tV1(0) to 0.0\n" +
                    "\tV2(0) to 0.0" );
            x.set(0, 0.0);
            yUpper.set(0, 0.0);
            yLower.set(0, 0.0);
        }

        if(x.get(breakPoint-1) != 1.0)
        {
            StreamService.print("X(NPOINTS) is not 0.0 as per DATCOM requirements, overriding:\n" +
                    "\tX(NPOINTS)  to 1.0\n" +
                    "\tV1(NPOINTS) to 0.0\n" +
                    "\tV2(NPOINTS) to 0.0" );
            x.set(npts-1, 1.0);
            yUpper.set(npts-1, 0.0);
            yLower.set(npts-1, 0.0);
        }

        // Write the values to the table
        for (int i = 0; i < npts; i++) {
            jTable1.setValueAt(x.get(i), i, 0);
            jTable1.setValueAt(yUpper.get(i), i, 1);
            jTable1.setValueAt(yLower.get(i), i, 2);
        }

        jNPTS.setText(String.valueOf(npts));
        DataServer.getInstance().getLink(prefix + "AIRFOIL").clear();
    }//GEN-LAST:event_jImportAirfoilActionPerformed

    private void jClearTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jClearTableActionPerformed
        // TODO add your handling code here:
        ProjectWizard p = new ProjectWizard(OpenDatcomController.getInstance().getMainFrame(), true);
        p.setVisible(true);
    }//GEN-LAST:event_jClearTableActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField jALPHAI;
    private javax.swing.JTextField jARCC;
    private javax.swing.JTextField jAirfoilName;
    private javax.swing.JTextField jCLAM0;
    private javax.swing.JTextField jCLI;
    private javax.swing.JTextField jCLMAXL;
    private javax.swing.JTextField jCM0;
    private javax.swing.JTextField jCM0T;
    private javax.swing.JButton jClearTable;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JTextField jDELTAY;
    private javax.swing.JButton jImportAirfoil;
    private javax.swing.JTextField jKSHARP;
    private javax.swing.JTextField jLER0;
    private javax.swing.JTextField jLERI;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jNPTS;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jT0VC;
    private javax.swing.JTextField jT0VC0;
    private javax.swing.JTextField jTCEFF;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel jTitle;
    private javax.swing.JTextField jX0VC;
    private javax.swing.JTextField jX0VC0;
    // End of variables declaration//GEN-END:variables

    public JTextField getjALPHAI() {
        return jALPHAI;
    }


    public JTextField getjARCC() {
        return jARCC;
    }

    public JTextField getjCLAM0() {
        return jCLAM0;
    }

    public JTextField getjCLI() {
        return jCLI;
    }

    public JTextField getjCLMAXL() {
        return jCLMAXL;
    }

    public JTextField getjCM0() {
        return jCM0;
    }

    public JTextField getjCM0T() {
        return jCM0T;
    }

    public JTextField getjDELTAY() {
        return jDELTAY;
    }

    public JTextField getjKSHARP() {
        return jKSHARP;
    }

    public JTextField getjLER0() {
        return jLER0;
    }

    public JTextField getjLERI() {
        return jLERI;
    }

    public JTextField getjT0VC() {
        return jT0VC;
    }

    public JTextField getjT0VC0() {
        return jT0VC0;
    }

    public JTextField getjTCEFF() {
        return jTCEFF;
    }

    public JTextField getjX0VC() {
        return jX0VC;
    }

    public JTextField getjX0VC0() {
        return jX0VC0;
    }

    
}
